// gridito init
$("div.gridito").livequery(function () {
    $(this).gridito();
});

$(function () {
    $('<div id="ajax-spinner"></div>').appendTo("body").ajaxStop(function () {
        $(this).hide().css({
            position: "fixed",
            left: "50%",
            top: "50%"
        });
    }).hide();

    LiveForm.options = {
        controlErrorClass: 'form-control-message',
        errorMessageClass: 'form-error-message',
        validMessageClass: 'form-valid-message',
        showValid: false,
        messageTag: 'span',
        messageIdPostfix: '_message'
    }
});

/* AJAX na pdkazech */
$("a.ajax").live("click", function (event) {
    event.preventDefault();

    $.get(this.href);

    $("#ajax-spinner").show().css({
        position: "absolute",
        left: event.pageX + 15,
        top: event.pageY + 15
    });
});

/* AJAXové odeslání formulářů */
$("form.ajax").live("submit", function (event) {
    $("#ajax-spinner").show().css({
        position: "absolute",
        left: event.pageX + 15,
        top: event.pageY + 15
    });

    $(this).ajaxSubmit();
    return false;
});

$("form.ajax :submit").live("click", function (event) {
    $("#ajax-spinner").show().css({
        position: "absolute",
        left: event.pageX + 15,
        top: event.pageY + 15
    });

    $(this).ajaxSubmit();
    return false;
});
